public class ResetPassword {
    public static String decryption(String str){  //解密
        if(str.length()>16){       //审查
            return "请设定密码长度不超过16";  
        }
        else{
            StringBuffer password = new StringBuffer(str);
            password.reverse();  //先反转
            char temp = password.charAt(0);
            password.setCharAt(0, password.charAt(password.length()-1));
            password.setCharAt(password.length()-1,temp);   //交换第一位和最后一位
            for(int i = 0;i < str.length();i++){
                password.setCharAt(i, (char)(password.charAt(i)-(i+1)-3));
            }  //回到开始值
            return "解密后的结果是: " + password.toString();
            }
    }
}
